Skip to content

[docs][performance] Fix excessive use of layers - #4476

Merged
aarongarciah merged 2 commits into
mui:masterfrom
oliviertassinari:fix-layerize-time
Jun 11, 2026
Merged

[docs][performance] Fix excessive use of layers#4476
aarongarciah merged 2 commits into
mui:masterfrom
oliviertassinari:fix-layerize-time

Conversation

@oliviertassinari

@oliviertassinari oliviertassinari commented Mar 29, 2026

Copy link
Copy Markdown
Member

When running this script mui/mui-x#11866 (comment) on the yet to be released Base UI Data Grid, the work the browser does is distributed like this over 1,000ms:

SCR-20260330-cueh

As it turned out, it's a problem with the docs-infra, not the data grid. It reproduces in different places. The issue has been introduced in #866.


Before: https://base-ui.com/react/components/autocomplete#virtualized, try to scroll the list. 566ms in rendering vs. 732ms of total

SCR-20260330-ckde

After: https://deploy-preview-4476--base-ui.netlify.app/react/components/autocomplete#virtualized. 174ms in rendering vs. 495 ms of total. So it's 47% faster.

SCR-20260330-cmyd

The gain simply comes from going from 235 layers on the page to 74 layers. overscroll-behavior-x is forcing the promotion of the element to its own layers.

I have removed from the API table where the element was not scrollable, those were not providing value:

SCR-20260330-cpjp

I have also removed it from the code demo header, where the UX felt wrong:

SCR-20260330-cpmv

We still have too many layers, but it's not as many as before, and the changes in this PR should be non-controversial. After, we can discuss how to bring it a step further.

@oliviertassinari oliviertassinari added performance scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). labels Mar 29, 2026
@pkg-pr-new

pkg-pr-new Bot commented Mar 29, 2026

Copy link
Copy Markdown

commit: ea7368b

@mui-bot

mui-bot commented Mar 29, 2026

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Mar 29, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit ea7368b
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a2acb73db9df100086515f8
😎 Deploy Preview https://deploy-preview-4476--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks atomiks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice ~ I didn't find any regressions when elements need to actually overflow.

@cherniavskii cherniavskii left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me 👍🏻
I checked the docs on iOS – didn't spot any issues

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 11, 2026

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 0B(0.00%) 0B(0.00%)

Details of bundle changes

Performance

Total duration: 1,094.00 ms ▼-430.44 ms(-28.2%) | Renders: 50 (+0) | Paint: 1,648.25 ms ▼-633.73 ms(-27.8%)

Test Duration Renders
Tabs mount (200 instances) 215.44 ms ▼-104.97 ms(-32.8%) 4 (+0)
Menu mount (300 instances) 117.73 ms ▼-79.64 ms(-40.4%) 2 (+0)
Select mount (200 instances) 132.21 ms ▼-79.41 ms(-37.5%) 3 (+0)
Mixed surface mount (app-like density) 68.12 ms ▼-37.98 ms(-35.8%) 5 (+0)
Tooltip mount (300 contained roots) 41.94 ms ▼-34.13 ms(-44.9%) 1 (+0)

…and 1 more (+6 within noise) — details


Check out the code infra dashboard for more information about this PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces excessive composited layers in the docs UI by removing unconditional overscroll-behavior-x: contain and applying it only where horizontal scrolling actually occurs, improving scroll performance across docs pages.

Changes:

  • Apply overscroll-behavior-x: contain conditionally for scrollable Table/Accordion cells (via [data-scrollable]) to reduce layer promotion.
  • Remove overscroll-behavior-x: contain from the CodeBlock header panel to avoid unnecessary layers / undesirable UX.
  • Keep horizontal gesture prevention where still needed (e.g., code viewport).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
docs/src/components/Table.css Makes overscroll containment conditional for table cells to reduce layer count.
docs/src/components/CodeBlock/CodeBlock.css Removes overscroll containment from the code block header scroll container.
docs/src/components/Accordion.css Makes overscroll containment conditional for accordion scrollable rows to reduce layer count.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/src/components/Table.css
@aarongarciah
aarongarciah marked this pull request as ready for review June 11, 2026 15:48
@aarongarciah
aarongarciah self-requested a review as a code owner June 11, 2026 15:48
@aarongarciah aarongarciah changed the title [docs] Fix excessive use of layers [docs][performance] Fix excessive use of layers Jun 11, 2026
@aarongarciah
aarongarciah merged commit fb7d80e into mui:master Jun 11, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants